from injector import  inject
from dataclasses import dataclass
from internal.service.acccount_service import AccountService
from internal.schema.proxy_schema import ProxySchema
from pkg.resp import validate_error_json, success_message


@inject
@dataclass
class ProxyHandler:
    acoount_service: AccountService
    #代理模式
    def set_proxy(self):
        req = ProxySchema()
        if not req.validate():
            return validate_error_json(req.errors)
        self.acoount_service.add_proxy(req.secret_id.data,req.secret_key.data)
        return success_message()

